<?php

namespace App\Http\Middleware;

use Closure;
use Nette\Mail\Message;
use Nette\Mail\SendmailMailer;

class Mail
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $rs = $next($request);
        $mail = new Message;
        $mail->setFrom('lhnjxdqq@163.com')
            ->addTo('262264620@qq.com')
            ->setSubject('欢迎注册ddd')
            ->setBody("你好,这事了测试,没别的意思.");
        // $mailer = new \Nette\Mail\SmtpMailer(array(
        //         'host' => 'smtp.163.com',
        //         'username' => 'lhnjxdqq',
        //         'password' => 'lhnjxdqq5488016',
        //         'secure' => 'ssl',
        // ));


$mailer = new \Nette\Mail\SendmailMailer;
// $mailer->send($mail);
        return $rs;
    }
}
